package top.igotcha.servicebase.config;

/**
 * @author Gotcha
 * @date 2021/8/2
 * @describe
 */
//@WebFilter(filterName = "GlobalCorsConfig")
//@Configuration
//public class GlobalCorsConfig implements Filter {
//    @Override
//    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException, ServletException {
//        HttpServletResponse response = (HttpServletResponse) res;
//        HttpServletRequest request = (HttpServletRequest) req;
//
//        String origin = request.getHeader("origin");
//        if (StringUtils.isEmpty(origin)) {
//            origin = "*";
//        }
//        response.setHeader("Access-Control-Allow-Origin", origin);
//        response.setHeader("Access-Control-Allow-Credentials", "true");
//        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PATCH, DELETE, PUT");
//        response.setHeader("Access-Control-Max-Age", "3600");
//        response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
//        chain.doFilter(req, res);
//    }
//}